package net.xdclass.base_project.consumer;

import net.xdclass.base_project.config.SpringConfigConstant;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.annotation.TopicPartition;

import java.util.List;

/**
 * @author sqz
 * @Description: kafka监听多topic
 * @date 2019/9/26 11:06
 */
public class KafkaTopicLintener {

    private final Logger log = LoggerFactory.getLogger(KafkaTopicLintener.class);

    @KafkaListener(topics = {SpringConfigConstant.KAFKA_FIRST_TOPIC})
    public void topicListener(List<ConsumerRecord<String, String>> records) {
        log.info("批量拉取的数据数量:{}:",records.size());
        records.forEach(record->{
//            log.info("message{}:",String.valueOf(record.value()));
        });
    }
}

